/**  

* <p>Title: GoodsController.java</p>  

* <p>Description: </p>  

* <p>Company: ���ƿƼ�</p>  

* @author javafengyu  

* @date 2019��4��12��  

* @version 1.0  

*/  
package com.zb.web.controller;

import com.zb.model.TGoods;
import com.zb.model.TGoodsDetail;
import com.zb.service.impl.GoodsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;


@Controller
@RequestMapping("/web")
public class GoodsController {

	@Autowired
	private GoodsServiceImpl gs;
	
	private int counter=0;
	

	@RequestMapping("/SelectGoods")
	public String selectGoods(HttpSession session) {
		System.out.println("goods select begin");
		List<TGoods> goodsList = gs.selectGoodsService();
		System.out.println("Goods select over");
		session.setAttribute("goodsList", goodsList);
		return "homePage";
	}
	

	@RequestMapping("/SelectGoodsByCate")
	public String selectGoodsByCate(String cateid,HttpSession session,HttpServletRequest request) {
		//cateid=request.getParameter("thegoodid");
		List<TGoods> goodsList = gs.selectGoodsByCateService(cateid);
		session.setAttribute("goodsList"+cateid, goodsList);
		return "homePage";
	}
	

	@RequestMapping("/SelectGoodsMsgById")
	public String selectGoodsById(String goodsId,HttpSession session,HttpServletRequest request) {
		//System.out.println(goodsId);
		goodsId=request.getParameter("goodid");
		TGoods tg=gs.selectGoodsByIdService(goodsId);
//		TGoodsDetail tgd=gs.selectGoodsDetailByIdService(goodsId);
		System.out.println(tg);
		session.setAttribute("good", tg);
		session.setAttribute("goodstock", tg.getGoodsStock());
//		session.setAttribute("goodDetail", tgd);
		return "item_show";
	}
	

}
